#include <iostream>

using namespace std;

typedef long long LL;

LL m, n;

LL gcd(LL a, LL b)
{
	return b == 0 ? a : gcd(b, a % b);
}

int main()
{
//	cout << gcd(6, 3) << endl;
	cin >> m >> n;
	m++; n++;
	LL ret1 = (n * m) * (n * m - 1) * (n * m - 2) / 6;
	LL ret2 = n * (n - 1) * (n - 2) / 6 * m;
	LL ret3 = m * (m - 1) * (m - 2) / 6 * n;
	LL ret4 = 0;
	for(int i = 1; i < n; i++)
		for(int j = 1; j < m; j++)
			ret4 += (n - i) * (m - j) * (gcd(i, j) - 1);
	cout << ret1 - ret2 - ret3 - 2 * ret4 << endl;	
	return 0;
} 
